feat(search): EXP-12 — log-spaced recency bins for TR and MR#6
Draft
moralespanitz wants to merge 1 commit intomainfrom
Draft
feat(search): EXP-12 — log-spaced recency bins for TR and MR#6moralespanitz wants to merge 1 commit intomainfrom
moralespanitz wants to merge 1 commit intomainfrom
Conversation
Adds a coarse log-spaced recency tag at ingest time and a matching boost stage at retrieval time, behind the new feature flag `recencyBinBoostEnabled`. Bins: 1m, 10m, 1h, 10h, 1d, 10d, 100d, older. At ingest, every fact gets metadata.recency_bin set from now - created_at. At retrieval, inferQueryBin() reads the query text (e.g. "yesterday", "last week", "right now") and returns the bin that matches; the boost stage adds recencyBinBoostWeight to facts whose stored bin matches the inferred query bin. The stage runs after current-state-ranking and short-circuits when current-state-ranking already fired (to avoid double-counting). Targets BEAM TR and MR. Sprint 2 dry-run on iter 7 v3 had TR 1/2 and MSR 0/2 — log-spaced bins are the cheapest first cut at temporal disambiguation. New config keys (defaults-off): - recencyBinBoostEnabled: false - recencyBinBoostWeight: 0.10 Both are config-override-allowlisted for per-request A/B via the BEAM adapter. RESERVED_METADATA_KEYS extended with 'recency_bin' for the metadata drift guard. Behind feature flags. Defaults preserve current behavior.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
BEAM Sprint 2 dry-run (iter 7 v3) is leaving temporal-reasoning (TR) and multi-session-reasoning (MR/MSR) probes on the table: TR 1/2, MSR 0/2 in the latest run, well below the Honcho TR=0.644 / MR=0.631 reference. Raw
created_attimestamps don't match query phrasing like "recently" or "last week"; the retrieval path needs a coarser, scale-invariant signal it can match against.Log-spaced recency bins are the cheapest first cut at this — Blueprint M5 calls out "AtomicMemory has naive timestamps … No Laplace bank, no drift vector, no scale-invariant representation"; log bins approximate Laplace at ~5% of the cost.
What
EXP-12 from
phase2-implementation-plans-2026-04-29.md. Two pieces:storeProjectioncarriesmetadata.recency_bin(a debug breadcrumb; retrieval recomputes fromcreated_at).applyRecencyBinBooststage in the search pipeline runs afterapplyCurrentStateRankingand beforeapplyConcisenessPenalty. When the query has a recognizable recency marker, the stage addsrecencyBinBoostWeight × computeBinAffinity(queryBin, factBin)to each candidate'sscore(1.0 for exact bin match, 0.5 for an adjacent bin, 0 otherwise) and re-sorts. Skipped entirely when current-state-ranking already triggered, to avoid double-counting two recency-flavored signals.Bin schema (and why log-spaced)
Constant ratio (~10×) per rung. Adjacent bins are close in human terms ("yesterday" vs "last week" feel related), so we award half-credit for adjacency. BEAM conversations span minutes-to-months simulated; a fixed-stride scheme would either lose minutes-scale resolution or balloon the bin count.
Config-override copy-paste (defaults-off)
{ "config_override": { "recencyBinBoostEnabled": true, "recencyBinBoostWeight": 0.10 } }Both keys are in
INTERNAL_POLICY_CONFIG_FIELDS. Env-var equivalents areRECENCY_BIN_BOOST_ENABLEDandRECENCY_BIN_BOOST_WEIGHT.How it composes with EXP-05
Independent. EXP-05 touches
extraction-enrichment.ts,memory-service-types.ts,memory-storage.ts:96(instruction-tag), andsearch-pipeline.ts:755-761(instruction boost). EXP-12 touchestemporal-fingerprint.ts,temporal-query-expansion.ts,recency-bin-ranking.ts(new),memory-storage.ts:96(recency-bin breadcrumb), and the same protection-stage block insearch-pipeline.ts. Both share that protection-stage block but write distinct stages — instruction-boost goes between current-state-ranking and conciseness-penalty; recency-bin-boost goes immediately after current-state-ranking. TheRESERVED_METADATA_KEYSset is the only collision point — EXP-05 addedfact_role, EXP-12 addsrecency_bin. Both keys are pre-allowlisted for the metadata drift guard.Test plan
src/services/__tests__/temporal-fingerprint.test.ts— bin assignment table tests (boundary cases at 1m, 10m, 1h, 10h, 1d, 10d, 100d, plus future-dated clamp) andcomputeBinAffinity(exact / adjacent / non-adjacent).src/services/__tests__/recency-bin-ranking.test.ts— boost applied when enabled, no-op onweight=0, no-op on unrecognizable queries, short-circuit when current-state-ranking already triggered, weight applied as configured, recompute-from-created_at(ignores stale persisted hints).src/__tests__/reserved-metadata-keys.test.ts(drift guard) — passes with'recency_bin'added.src/__tests__/config-partition.test.ts— passes with new keys inINTERNAL_POLICY_CONFIG_FIELDS.npx tsc --noEmit— clean.recencyBinBoostEnabled: true— pending dry-run iter onfeature/exp-12-log-spaced-recency-bins.Rollback
recencyBinBoostEnabled: false(default). The persistedmetadata.recency_binfield is harmless metadata; no migration is needed if the flag is disabled or the feature is reverted.